<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('项目名称') }}</td>
        <td>{{ form.dealName }}</td>
        <td class="tit">{{ $t('标的公司名称') }}</td>
        <td>{{ form.companyName }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('委托评估/审计单位') }}</td>
        <td>{{ form.auditUnit }}</td>
        <td class="tit">{{ $t('拟进场时间') }}</td>
        <td>{{ parseTime(form.entryTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('报价最高限价') }}{{ $t('金额单位') }}</td>
        <td>{{ moneyFormat(form.priceCeiling, 'w') }}</td>
        <td class="tit">{{ $t('主体类型') }}</td>
        <td>
          <dictSelect
            v-model="form.investType"
            dictionary="main_body_type"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('主体名称') }}</td>
        <td>
          <MainBodySelect
            v-model="form.investId"
            :parameters="form.investType"
          />
        </td>
        <td class="tit">{{ $t('选聘类型') }}</td>
        <td>
          <el-select v-model="form.selectType" multiple :placeholder="$t('选聘类型')">
            <el-option
              v-for="dict in selectTypeOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('项目实施依据') }}</td>
        <td colspan="3">{{ form.dealImpl }}</td>
      </tr>
    </table>
    <div v-if="form.dealWfBidIntermediaryList && form.dealWfBidIntermediaryList.length > 0">
      <div class="area-header" style="margin-top:10px;">
        <span class="area-header-title">{{ $t('拟招标中介机构') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('中介机构名称') }}</th>
          <th>{{ $t('中介报价') }}{{ $t('金额单位') }}</th>
          <th>{{ $t('是否中标') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.dealWfBidIntermediaryList" :key="ind">
            <td>
              <el-select v-model="v.mediationId">
                <el-option
                  v-for="(item, index) in mediationTypeOptions"
                  :key="index"
                  :label="item.mediationName"
                  :value="item.id"
                />
              </el-select>
            </td>
            <td>{{ moneyFormat(v.offer, 'w') }}</td>
            <td>{{ bidFormat(v.bid) }}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
import { getDealWfIntermediary } from '@/api/deal/intermediary/dealWfIntermediary'
import MainBodySelect from '@/components/MainBodySelect/index'
import { findByTypeList } from '@/api/deal/mediation/mediationBase'
export default {
  components: {
    MainBodySelect
  },
  data() {
    return {
      selectTypeOptions: [],
      sysYesNoOptions: [],
      form: {
        dealWfBidIntermediaryList: []
      },
      loading: false,
      mediationTypeOptions: []
    }
  },
  created() {
    this.getDicts('intermediary_type').then(response => {
      this.selectTypeOptions = response.data
    })
    this.getDicts('sys_yes_no').then((response) => {
      this.sysYesNoOptions = response.data
    })
  },
  mounted() {
    this.$bus.$emit('async_done')
  },
  methods: {
    // 初始化数据
    init(data) {
      if (data != null && data.id !== undefined) {
        getDealWfIntermediary(data.id).then((response) => {
          this.form = response.data
          findByTypeList(response.data.selectType).then((response) => {
            this.mediationTypeOptions = response.data
          })
        })
      }
    },
    bidFormat(row) {
      return this.selectDictLabel(this.sysYesNoOptions, row)
    }
  }
}
</script>
